package arrays27;

import java.util.*;

public class Main {
	public static void main(String[] args) {
		int[] nums = {0, 0, 0, 1, 1, 1, 0, 0};
		int val = 0;
		int i = size(nums, val);
		System.out.print(i);
		for (int j : nums) {
			System.out.print(j);
		}
	}
	
	public static int size(int[] nums, int val) {
		int left = 0;
        int right = nums.length;
        while (left < right) {
            if(nums[left] == val) {
                nums[left] = nums[right - 1];
                right--;
            }else left++;
        }
		return left;
	}
}
